$.ajax({
    'url': '../电影json/opera.json',
    // 'url': 'https://www.fastmock.site/mock/bb4157f45a0b5ffdcb3f6d984517a6c0/woniuMovie/getAllOperas',
    "success": function (data) {
        var cinema = data.operas;
        console.log(cinema);
        for (let i = 0; i < cinema.length; i++) {
            additem(cinema[i]);
        };

        //点击地图事件
        $('.clickMap').on('click', function () {
            var p = $(this).text();
            console.log(p);
            newMap(p);
            $('#result').text(p);
            $('.baidu').show();
        });
        //隐藏地图
        $('#closeMap').click(function () {
            $('.baidu').hide();
        });

        //点击地图跳转
        $('.cinema-place').click(function () {
            var i = $(this).parent().index() + 1;
            console.log(i);
            location.href = `cinema-content.html?${i}`;
        })

    }

});

//遍历
function additem(e) {
    $('.main').append(` 
    <div class="container">
    <img class="cinema-place" src="${e.img_src}" alt="">
    <div class="left-container">
        <p>${e.name}</p>
        <div>
            <img id="location-logo" src="../img/detail/position.png" alt="">
            <span class='clickMap'>${e.address}</span>
        </div>

    </div>
</div>
        `);
};

